/*
 * AppMainFrame.java
 *
 * Created on November 21, 2006, 1:49 AM
 */

package jx.swing.board.app;

import javax.swing.SwingUtilities;
import jx.swing.board.event.DefaultGameController;
import jx.swing.board.model.CellType;
import jx.swing.util.ResourceManager;

/**
 *
 * @author  Administrator
 */
public class AppMainFrame extends javax.swing.JFrame {
    DefaultGameController controller;
    /** Creates new form AppMainFrame */
    public AppMainFrame() {
        initComponents();
        controller = new DefaultGameController();
        controller.setBoard(board1);
        controlPanel1.setController(controller);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        controlPanel1 = new jx.swing.board.ControlPanel();
        board1 = new jx.swing.board.Board();
        jLabel1 = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        jButton1 = new javax.swing.JButton();
        rowBox = new javax.swing.JComboBox();
        colBox = new javax.swing.JComboBox();
        newGameBtn = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        redLabel = new javax.swing.JLabel();
        orangeLabel = new javax.swing.JLabel();
        greenLabel = new javax.swing.JLabel();
        blueLabel = new javax.swing.JLabel();
        magenatLabel = new javax.swing.JLabel();
        totalScoreLabel = new javax.swing.JLabel();
        timerLabel = new javax.swing.JLabel();
        
        
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("JawBreaker v1.0  ");
        board1.setLayout(new java.awt.BorderLayout());
        
        getContentPane().add(board1, java.awt.BorderLayout.CENTER);
        
        jLabel1.setText(" JawBreaker v1.0  written by yuezhong");
        getContentPane().add(jLabel1, java.awt.BorderLayout.PAGE_END);
        
        jButton1.setText("jButton1");
        jToolBar1.add(jButton1);
        
        rowBox.setEditable(true);
        rowBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "8", "10", "12", "14", "16", "18", "20" }));
        rowBox.setName("Row");
        jToolBar1.add(rowBox);
        
        colBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "8", "10", "12", "14", "16", "18", "20" }));
        jToolBar1.add(colBox);
        
        newGameBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/reload_page.png")));
        newGameBtn.setBorderPainted(false);
        newGameBtn.setOpaque(false);
        newGameBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newGameBtnActionPerformed(evt);
            }
        });
        
        jToolBar1.add(newGameBtn);
        
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/redo.png")));
        jButton2.setBorderPainted(false);
        jButton2.setOpaque(false);
        jToolBar1.add(jButton2);
        
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/undo.png")));
        jButton3.setBorderPainted(false);
        jButton3.setOpaque(false);
        jToolBar1.add(jButton3);
        
        jPanel1.setLayout(new java.awt.GridLayout(7, 1));
        
        redLabel.setIcon(ResourceManager.getDefaultManager().getSmallIcon(CellType.RED));
        jPanel1.add(redLabel);
        
        orangeLabel.setIcon(ResourceManager.getDefaultManager().getSmallIcon(CellType.ORANGE));
        jPanel1.add(orangeLabel);
        
        greenLabel.setIcon(ResourceManager.getDefaultManager().getSmallIcon(CellType.GREEN));
        jPanel1.add(greenLabel);
        
        blueLabel.setIcon(ResourceManager.getDefaultManager().getSmallIcon(CellType.BLUE));
        jPanel1.add(blueLabel);
        
        magenatLabel.setIcon(ResourceManager.getDefaultManager().getSmallIcon(CellType.MAGENTA));
        jPanel1.add(magenatLabel);
        
        jPanel1.add(totalScoreLabel);
        
        jPanel1.add(timerLabel);
        
        jToolBar1.add(jPanel1);
        
        getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);
        
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void newGameBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newGameBtnActionPerformed
// TODO add your handling code here:
        int row = Integer.parseInt((String)rowBox.getSelectedItem());
        int col = Integer.parseInt((String)colBox.getSelectedItem());
        controller.newGame(row,col);
        SwingUtilities.windowForComponent(this.getParent()).pack();
    }//GEN-LAST:event_newGameBtnActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AppMainFrame().setVisible(true);
            }
        });
    }
    
// Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel blueLabel;
    private jx.swing.board.Board board1;
    private javax.swing.JComboBox colBox;
    private jx.swing.board.ControlPanel controlPanel1;
    private javax.swing.JLabel greenLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLabel magenatLabel;
    private javax.swing.JButton newGameBtn;
    private javax.swing.JLabel orangeLabel;
    private javax.swing.JLabel redLabel;
    private javax.swing.JComboBox rowBox;
    private javax.swing.JLabel timerLabel;
    private javax.swing.JLabel totalScoreLabel;
// End of variables declaration//GEN-END:variables
    
    
}
